﻿using DependencyAnalysis.DataModel;
using NUnit.Framework;

namespace NUnitExample
{
    [TestFixture]
    public class ApprovedNamespacesTest : DependencyTest
    {
        [Test]
        public void AllowedNamespacesInAnalysisHost()
        {
            var module = DescriptorBuilder.BuildModuleDescriptor(typeof(AnalysisHost.Properties.IAssemblyIdentifier).Assembly);
            var main = DescriptorBuilder.BuildSubmoduleDescriptor(module, "AnalysisHost");
            var properties = DescriptorBuilder.BuildSubmoduleDescriptor(module, "AnalysisHost.Properties");

            Verifier.VerifySubmodulesInModule(module, new[] { main, properties });
        }

        [Test]
        public void AllowedNamespacesInDependencyAnalysis()
        {
            var module = DescriptorBuilder.BuildModuleDescriptor(typeof(DependencyAnalysis.Properties.IAssemblyIdentifier).Assembly);
            var main = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis");
            var properties = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis.Properties");
            var algorithms = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis.Algorithms");
            var algoSubstring = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis.Algorithms.SubstringDetection");
            var algoCycle = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis.Algorithms.CycleDetection");
            var dataModel = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis.DataModel");
            var internalSub = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis.Internal");
            var serialization = DescriptorBuilder.BuildSubmoduleDescriptor(module, "DependencyAnalysis.Serialization");
            var generated = DescriptorBuilder.BuildSubmoduleDescriptor(module, "");

            Verifier.VerifySubmodulesInModule(module, new[] { main, properties, algorithms, dataModel, internalSub, serialization, algoCycle, algoSubstring, generated });
        }

        [Test]
        public void AllowedNamespacesInCommonAddin()
        {
            var module = DescriptorBuilder.BuildModuleDescriptor(typeof(theeg.DependencyAnalysis.CommonAddin.Properties.IAssemblyIdentifier).Assembly);
            var main = DescriptorBuilder.BuildSubmoduleDescriptor(module, "theeg.DependencyAnalysis.CommonAddin");
            var properties = DescriptorBuilder.BuildSubmoduleDescriptor(module, "theeg.DependencyAnalysis.CommonAddin.Properties");
            var behaviors = DescriptorBuilder.BuildSubmoduleDescriptor(module, "theeg.DependencyAnalysis.CommonAddin.Behaviors");
            var converters = DescriptorBuilder.BuildSubmoduleDescriptor(module, "theeg.DependencyAnalysis.CommonAddin.Converters");
            var controls = DescriptorBuilder.BuildSubmoduleDescriptor(module, "theeg.DependencyAnalysis.CommonAddin.Controls");
            var models = DescriptorBuilder.BuildSubmoduleDescriptor(module, "theeg.DependencyAnalysis.CommonAddin.Models");

            Verifier.VerifySubmodulesInModule(module, new[] { main, behaviors, converters, controls, models, properties });
        }
    }
}
